﻿@*
    *
    * F. Mehmet ARSLAN (c) 2015
    * fmehmetarslan46@gmail.com
    *
*@
@model ServerManager.Models.ServicesState

@helper ServiceItem(ServerManager.Models.Service service)
{
    <service serviceid="@service.Id" method="@service.Method" url="@Html.Encode(service.Url)">
        @if (service.ChildService != null && service.ChildService.Count < 1) 
        { 
            <div class="state" id="@service.Id-state"></div>
        }
        else
        {
            <div class="state passive" id="@service.Id-state"></div>
        }
        <div class="description">
            @if ((service.ChildService == null || service.ChildService.Count < 1) && (service.Method == ServerManager.Models.Method.http || service.Method == ServerManager.Models.Method.file))
            {
                <a target="_blank" href="@service.getUrl">
                    @service.Description
                </a>
            }
            else
            {
                @service.Description
            }
        </div>
        @{
            if (service.ChildService != null && service.ChildService.Count > 0)
            {
                <servicegroup>
                    @{
                foreach (ServerManager.Models.Service childService in service.ChildService)
                {
                    @ServiceItem(childService);
                }
                }
            </servicegroup>
            }
        }
    </service>
}

<div class="state-dashboard">
    <info class="state-info">
        <ul>
            <li>
                <state class="state state-200"></state>
                <description>Çalışır Durumda</description>
            </li>
            <li>
                <state class="state state-401"></state>
                <description>Yetki Gerekiyor</description>
            </li>
            <li>
                <state class="state state-404"></state>
                <description>Sayfa Bulunamadı</description>
            </li>
            <li>
                <state class="state state-500"></state>
                <description>Ulaşılamıyor</description>
            </li>
            <li>
                <state class="state state-204"></state>
                <description>Sonuç Hatalı</description>
            </li>
            <li>
                <state class="state state-303"></state>
                <description>Durum Kontrol Ediliyor</description>
            </li>
            <li>
                <state class="state passive"></state>
                <description>Pasif Servis</description>
            </li>
            <li>
                <state class="state"></state>
                <description>Diğer Durumlar</description>
            </li>
        </ul>
    </info>
    @{
        if (Model != null) { 

        foreach (var serviceGroup in Model.ServiceGroup)
        {
            <div id="@serviceGroup.Id" class="service-state">
                <title>@serviceGroup.Title</title>
                <loader><img src="~/Resources/Image/ajax-loader.gif"/></loader>
                <servicegroup>
                    @{
            foreach (ServerManager.Models.Service service in serviceGroup.Services)
            {
                @ServiceItem(service);
            }
                    }
                </servicegroup>
            </div>
        }
        }
        else
        {
            <h5 class="alert-text">Servis listesi yok veya hatalı kaydedilmiştir.</h5>
        }

    }
    
</div>